package ru.sushka.lunch.util;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.util.Properties;

public class LynchProperties {
    
    private static final String PROPS_FILE = "./lunchy.xml";
    private static Properties lunchProps;
    
    public static final void load() {
        String fileName = PROPS_FILE;
        File file = new File(fileName);
        setDefault();
        try {
            FileInputStream fi = new FileInputStream(file);
            lunchProps.loadFromXML(fi);
            fi.close();
        } catch (Exception ex) {
            ex.printStackTrace();
           
        }
    }
    
    public static final void save() {
        String fileName = PROPS_FILE;
        File file = new File(fileName);
        try {
            FileOutputStream fo = new FileOutputStream(file);
            lunchProps.storeToXML(fo,"Lunchy properties");
            fo.close();
           
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }

    public static final void setDefault() {
        lunchProps = new Properties();
        lunchProps.setProperty("MenuExpiryDate", "0");
    }    
}
